import java.io.*;

public class servableFile {

	private String _fileContents="";
	private String _mimeType="";
	
	public servableFile(String filepath, String mimeType){
		this._mimeType=mimeType;
		this._fileContents=getContents(filepath);
	}
	
	public String getFileContents(){
		return _fileContents;
	}
	public String getMimeType(){
		return _mimeType;
	}
	

	//get the contents out of the file.  MUST be a resource file contained w/ the package
	  private String getContents(String theFile) {
	    StringBuilder contents = new StringBuilder();
	    
	    InputStream is = getClass().getResourceAsStream("/" + theFile);
	    
	    try {
	      BufferedReader reader =  new BufferedReader(new InputStreamReader(is));
	      try {
	        String line; //not declared within while loop
	        while (( line = reader.readLine()) != null){
	          contents.append(line);
	          contents.append("\r\n");
	        }
	      }
	      finally {
	        reader.close();
	      }
	    }
	    catch (IOException ex){
	      ex.printStackTrace();
	    }
	    return contents.toString();
	  }

}
